#include "ScnsPower.c.h"

#if defined(SCNS_POWER_ENABLE)&&SCNS_POWER_ENABLE==1

#include "ScnsMenu.h"
#include "ScnsVofa.h"

//static uint16 origin;
ScnsPowerStatus scnsBspPowerInit(void)
{
    adc_init(ADC_2,ADC2_CH08_B00,ADC_12BIT);
    return SCNS_POWER_STATUS_OK;
}

ScnsPowerStatus scnsBspPowerPostInit(void)
{
    //scnsMenuAddConst(0,origin,,SCNS_TYPE_INT16);
    return SCNS_POWER_STATUS_OK;
}

float scnsBspPowerGetVoltage(void)
{
    uint16 origin=adc_convert(ADC_2,ADC2_CH08_B00);
    return -0.843044820944471+0.00202948445401926*origin;
}

ScnsPowerStatus scnsBspPowerIfNeedCharge(float u)
{
    return u<3.6?SCNS_POWER_STATUS_NEED_CHARGE:SCNS_POWER_STATUS_OK;
}

#endif